Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Compatibility Preparation #2

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

creambyemute
Copy link

Hey there!

I've been using your fork for some time now and thought I may contribute something small back ;-).
I've made some small changes to the index.js to prepare for Windows paths compatibility.

I'll remove the changes to yarn.lock and package.json if you'd be fine with merging the index.js changes.

The RN-FS windows support PR should merged rather sooner than later and this would prepare the Library for it.

Have already tested on Android & Windows & iOS

Comment on lines +7 to +11
const OSPathSeparator = Platform.select({
ios: "/",
android: "/",
windows: "\\",
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to use path? if so you can just use path.sep if you need access to the separator

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so as it's React-Native JS world and not node.js?

Comment on lines +13 to +20
const resolvePath = (...paths: Array<string>) => {
if (Platform.OS === "windows") {
return paths
.join(OSPathSeparator)
.split(OSPathSeparator)
.filter((part) => part && part !== ".")
.join(OSPathSeparator);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you're able to use path then I think this is the same as path.normalize with a trailing separator?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants